package com.chilly.other.jvm;

/**
 * 堆溢出
 * 堆是存放对象的地方，那么只要在堆中疯狂的创建对象，那么堆就会发生内存溢出。
 * Created by Chilly Cui on 2020/12/21.
 */
public class JvmOOM {
    // -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\env\jvmlog
    private static byte[] byteArray = new byte[100*1024*1024];

    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 100; i++) {
            builder.append(new String(byteArray));
        }
    }

}
